<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Get datafeed statistics API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'ml-get-datafeed-stats.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-get-datafeed-stats.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-get-datafeed-stats.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/ml-get-datafeed-stats.html" rel="nofollow" target="_blank">../en/ml-get-datafeed-stats.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="ml-apis.html">Machine learning anomaly detection APIs</a></span>
»
<span class="breadcrumb-node">Get datafeed statistics API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="ml-get-datafeed.html">« Get datafeeds API</a>
</span>
<span class="next">
<a href="ml-get-influencer.html">Get influencers API »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="ml-get-datafeed-stats"></a>Get datafeed statistics API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Retrieves usage information for datafeeds.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET _ml/datafeeds/&lt;feed_id&gt;/_stats</code><br></p>
<p><code class="literal">GET _ml/datafeeds/&lt;feed_id&gt;,&lt;feed_id&gt;/_stats</code><br></p>
<p><code class="literal">GET _ml/datafeeds/_stats</code> <br></p>
<p><code class="literal">GET _ml/datafeeds/_all/_stats</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
If the Elasticsearch security features are enabled, you must have <code class="literal">monitor_ml</code>,
<code class="literal">monitor</code>, <code class="literal">manage_ml</code>, or <code class="literal">manage</code> cluster privileges to use this API. See
<a class="xref" href="security-privileges.html" title="Security privileges">Security privileges</a>.
</li>
</ul>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can get statistics for multiple datafeeds in a single API request by using a
comma-separated list of datafeeds or a wildcard expression. You can get
statistics for all datafeeds by using <code class="literal">_all</code>, by specifying <code class="literal">*</code> as the
<code class="literal">&lt;feed_id&gt;</code>, or by omitting the <code class="literal">&lt;feed_id&gt;</code>.</p>
<p>If the datafeed is stopped, the only information you receive is the
<code class="literal">datafeed_id</code> and the <code class="literal">state</code>.</p>
<div class="important admon">
<div class="icon"></div>
<div class="admon_content">
<p>This API returns a maximum of 10,000 datafeeds.</p>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-path-parms"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;feed_id&gt;</code>
</span>
</dt>
<dd>
<p>
(Optional, string)
Identifier for the datafeed. It can be a datafeed identifier or a wildcard
expression.
</p>
<p>If you do not specify one of these options, the API returns information about
all datafeeds.</p>
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-query-parms"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">allow_no_datafeeds</code>
</span>
</dt>
<dd>
<p>
(Optional, boolean)
Specifies what to do when the request:
</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
Contains wildcard expressions and there are no datafeeds that match.
</li>
<li class="listitem">
Contains the <code class="literal">_all</code> string or no identifiers and there are no matches.
</li>
<li class="listitem">
Contains wildcard expressions and there are only partial matches.
</li>
</ul>
</div>
<p>The default value is <code class="literal">true</code>, which returns an empty <code class="literal">datafeeds</code> array when
there are no matches and the subset of results when there are partial matches.
If this parameter is <code class="literal">false</code>, the request returns a <code class="literal">404</code> status code when there
are no matches or only partial matches.</p>
</dd>
</dl>
</div>
</div>

<div class="section child_attributes">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-results"></a>Response body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The API returns an array of datafeed count objects. All of these properties are
informational; you cannot update their values.</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">assignment_explanation</code>
</span>
</dt>
<dd>
(string)
For started datafeeds only, contains messages relating to the selection of a
node.
</dd>
<dt>
<span class="term">
<code class="literal">datafeed_id</code>
</span>
</dt>
<dd>
(string)
A numerical character string that uniquely identifies the
datafeed. This identifier can contain lowercase alphanumeric characters (a-z
and 0-9), hyphens, and underscores. It must start and end with alphanumeric
characters.
</dd>
<dt>
<span class="term">
<code class="literal">node</code>
</span>
</dt>
<dd>
<p>
(object)
For started datafeeds only, this information pertains to the node upon which the
datafeed is started.
</p>
<details open>
<summary class="title">Details</summary>
<div class="content">
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">attributes</code>
</span>
</dt>
<dd>
(object)
Lists node attributes such as <code class="literal">ml.machine_memory</code> or <code class="literal">ml.max_open_jobs</code> settings.
</dd>
<dt>
<span class="term">
<code class="literal">ephemeral_id</code>
</span>
</dt>
<dd>
(string)
The ephemeral ID of the node.
</dd>
<dt>
<span class="term">
<code class="literal">id</code>
</span>
</dt>
<dd>
(string)
The unique identifier of the node.
</dd>
<dt>
<span class="term">
<code class="literal">name</code>
</span>
</dt>
<dd>
(string)
The node name. For example, <code class="literal">0-o0tOo</code>.
</dd>
<dt>
<span class="term">
<code class="literal">transport_address</code>
</span>
</dt>
<dd>
(string)
The host and port where transport HTTP connections are accepted.
</dd>
</dl>
</div>
</div>
</details>
</dd>
<dt>
<span class="term">
<code class="literal">state</code>
</span>
</dt>
<dd>
<p>
(string)
The status of the datafeed, which can be one of the following values:
</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">starting</code>: The datafeed has been requested to start but has not yet started.
</li>
<li class="listitem">
<code class="literal">started</code>: The datafeed is actively receiving data.
</li>
<li class="listitem">
<code class="literal">stopping</code>: The datafeed has been requested to stop gracefully and is
completing its final action.
</li>
<li class="listitem">
<code class="literal">stopped</code>: The datafeed is stopped and will not receive data until it is
re-started.
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">timing_stats</code>
</span>
</dt>
<dd>
<p>
(object) An object that provides statistical information about timing aspect of
this datafeed.
</p>
<details open>
<summary class="title">Details</summary>
<div class="content">
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">average_search_time_per_bucket_ms</code>
</span>
</dt>
<dd>
(double)
The average search time per bucket, in milliseconds.
</dd>
<dt>
<span class="term">
<code class="literal">bucket_count</code>
</span>
</dt>
<dd>
(long)
The number of buckets processed.
</dd>
<dt>
<span class="term">
<code class="literal">exponential_average_search_time_per_hour_ms</code>
</span>
</dt>
<dd>
(double)
The exponential average search time per hour, in milliseconds.
</dd>
<dt>
<span class="term">
<code class="literal">job_id</code>
</span>
</dt>
<dd>
Identifier for the anomaly detection job.
</dd>
<dt>
<span class="term">
<code class="literal">search_count</code>
</span>
</dt>
<dd>
The number of searches run by the datafeed.
</dd>
<dt>
<span class="term">
<code class="literal">total_search_time_ms</code>
</span>
</dt>
<dd>
The total time the datafeed spent searching, in milliseconds.
</dd>
</dl>
</div>
</div>
</details>
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-response-codes"></a>Response codes<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">404</code> (Missing resources)
</span>
</dt>
<dd>
If <code class="literal">allow_no_datafeeds</code> is <code class="literal">false</code>, this code indicates that there are no
resources that match the request or only partial matches for the request.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="ml-get-datafeed-stats-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/ml/anomaly-detection/apis/get-datafeed-stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET _ml/datafeeds/datafeed-high_sum_total_sales/_stats</pre>
</div>
<div class="console_widget" data-snippet="snippets/1822.console"></div>
<p>The API returns the following results:</p>
<div class="pre_wrapper lang-console-result">
<pre class="programlisting prettyprint lang-console-result">{
  "count": 1,
  "datafeeds": [
    {
      "datafeed_id": "datafeed-high_sum_total_sales",
      "state": "started",
      "node": {
        "id": "2spCyo1pRi2Ajo-j-_dnPX",
        "name": "node-0",
        "ephemeral_id": "hoXMLZB0RWKfR9UPPUCxXX",
        "transport_address": "127.0.0.1:9300",
        "attributes": {
          "ml.machine_memory": "17179869184",
          "ml.max_open_jobs": "20"
        }
      },
      "assignment_explanation": "",
      "timing_stats": {
        "job_id" : "high_sum_total_sales",
         "search_count" : 27,
         "bucket_count" : 619,
         "total_search_time_ms" : 296.0,
         "average_search_time_per_bucket_ms" : 0.4781906300484653,
         "exponential_average_search_time_per_hour_ms" : 33.28246548059884
      }
    }
  ]
}</pre>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="ml-get-datafeed.html">« Get datafeeds API</a>
</span>
<span class="next">
<a href="ml-get-influencer.html">Get influencers API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>